package com.example.administrator.testc.UIAuto;/**
 * Created by Administrator on 2016/5/2 0002.
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public class MakeXml {

//    private final static String rootPath = "C:/Users/Administrator/Desktop/values/values-{0}x{1}/";
//
//    private final static float dw = 320f;//320px, 1单位长度=1px 640px, 1单位长度=2px
//    private final static float dh = 480f;
//
//    private final static String WTemplate = "<dimen name=\"x{0}\">{1}px</dimen>\n";
//    private final static String HTemplate = "<dimen name=\"x{0}\">{1}px</dimen>\n";
//    private static final String SUPPORT_DIMESION =
//            "320,480;480,800;480,854;540,960;600,1024;" +
//            "720,1184;720,1196;720,1280;768,1024;800,1280;1080,1812;1080,1920;1440,2560;";
//
//    public static void main(String[] args){
//        makeString(320, 480);
//        makeString(480, 800);
//        makeString(480, 854);
//        makeString(720, 1280);
//        makeString(1080, 1920);
//        makeString(1080, 1920);
//        makeString(1152, 1920);
//        makeString(1440, 2560);
//    }
//
//    public static void makeString(int w, int h){
//        StringBuffer sb = new StringBuffer();
//        sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
//        sb.append("<resources>");
//        float cellw = w / dw;
//        for (int i = 1; i < 320; i++){
//            sb.append(WTemplate.replace("{0}", i + "").replace("{1}", change(cellw * i) + ""));
//        }
//        sb.append(WTemplate.replace("{0}", "320").replace("{1}", w + ""));
//        sb.append("</resources>");
//
//        StringBuffer sb2 = new StringBuffer();
//        sb2.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
//        sb2.append("<resources>");
//        float cellh = h / dh;
//        for (int i = 1; i < 480; i++){
//            sb2.append(HTemplate.replace("{0}", i + "").replace("{1}", change(cellh * i) + ""));
//        }
//        sb2.append(HTemplate.replace("{0}", "320").replace("{1}", h + ""));
//        sb2.append("</resources>");
//
//        String path = rootPath.replace("{0}", h + "").replace("{1}", w + "");
//        File rootFile = new File(path);
//        if(!rootFile.exists()){
//            rootFile.mkdirs();
//        }
//        File layxFile = new File(path + "lay_x.xml");
//        File layyFile = new File(path + "lay_y.xml");
//
//        try {
//            PrintWriter pw = new PrintWriter(new FileOutputStream(layxFile));
//            pw.print(sb.toString());
//            pw.close();
//            PrintWriter pw2 = new PrintWriter(new FileOutputStream(layyFile));
//            pw2.print(sb.toString());
//            pw2.close();
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//    }
//
//    public static float change(float a) {
//        int temp = (int) (a * 100);
//        return temp / 100f;
//    }
}
